
<div class="title">My Profile</div>
<?php
$success = Yii::app()->user->getFlash('success');
if ($success) {
    ?>
    <div class='alert alert-success'><?php echo $success ?></div>
    <?php
}
?>
<?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'user-form',
    'enableAjaxValidation' => false,
    'enableClientValidation' => true,
    'clientOptions' => array(
	'validateOnSubmit' => true
    ),
    'htmlOptions' => array(
	'class' => 'form-horizontal',
	'enctype' => 'multipart/form-data'
    )
	));
?>
<div class="wrap-avatar-edit">
    <img src="<?php echo $model->getAvatarUrl('large'); ?>"/>
    <br><br>
    Select another avatar
    <br>
    <?php echo $form->fileField($model, 'avatar'); ?>   
</div>
<br>
<div class='title-menu'>Information</div>
<table>
    <tr>
	<td class='label-column-edit-user'>Birthday: </td>
	<td>	    
	    <?php
	    $day = date('d', strtotime($model->birthday));
	    $month = date('m', strtotime($model->birthday));
	    $yearBirth = date('Y', strtotime($model->birthday));
	    ?>

	    Month:
	    <select name="User[month]" class="short-select-sign-up">
		<?php
		for ($i = 1; $i <= 12; $i++) {
		    if ($month == $i) {
			echo "<option value='" . $i . "' selected>" . $i . "</option>";
		    } else {
			echo "<option value='" . $i . "'>" . $i . "</option>";
		    }
		}
		?>
	    </select>

	    Day:
	    <select name="User[day]" class="short-select-sign-up">
		<?php
		for ($i = 1; $i <= 30; $i++) {
		    if ($day == $i) {
			echo "<option value='" . $i . "' selected>" . $i . "</option>";
		    } else {
			echo "<option value='" . $i . "'>" . $i . "</option>";
		    }
		}
		?>
	    </select>

	    Year:
	    <select name="User[year]" class="year-select-sign-up">
		<?php
		$year = date('Y', time());
		for ($i = 0; $i <= 50; $i++) {
		    $j = $year - $i;
		    if ($yearBirth == $j) {
			echo "<option value='" . $j . "' selected>" . $j . "</option>";
		    } else {
			echo "<option value='" . $j . "'>" . $j . "</option>";
		    }
		}
		?>
	    </select>
	</td>
    </tr>
    <tr>
	<td  class='label-column-edit-user'>Height</td>
	<td><?php echo $form->dropDownList($model, 'height', User::getListHeight(), array('class' => 'select-on-profile')); ?></td>
    </tr>
    <tr>
	<td  class='label-column-edit-user'>Marital Status</td>
	<td><?php echo $form->dropDownList($model, 'marital', User::getListMarital(), array('class' => 'select-on-profile')); ?></td>
    </tr>
    <tr>
	<td  class='label-column-edit-user'>Ethnicity</td>
	<td><?php echo $form->dropDownList($model, 'ethnicity', User::getListEthnicity(), array('class' => 'select-on-profile')); ?></td>
    </tr>
    <tr>
	<td  class='label-column-edit-user'>Relationship</td>
	<td><?php echo $form->dropDownList($model, 'relationship', User::getListRelationship(), array('class' => 'select-on-profile')); ?></td>
    </tr>
    <tr>
	<td  class='label-column-edit-user'>Zodiac</td>
	<td><?php echo $form->dropDownList($model, 'zodiac', User::getListZodiac(), array('class' => 'select-on-profile')); ?></td>
    </tr>
    <tr>
	<td  class='label-column-edit-user'>Smoking Preference</td>
	<td><?php echo $form->dropDownList($model, 'smoking', User::getListSmoking(), array('class' => 'select-on-profile')); ?></td>
    </tr>   
    <tr>
	<td  class='label-column-edit-user'>General Build</td>
	<td><?php echo $form->dropDownList($model, 'general_build', User::getListBuild(), array('class' => 'select-on-profile')); ?></td>
    </tr>
    <tr>
	<td  class='label-column-edit-user'>Children</td>
	<td><?php echo $form->dropDownList($model, 'children', User::getListChildren(), array('class' => 'select-on-profile')); ?></td>
    </tr>
    <tr>
	<td  class='label-column-edit-user'>Religion</td>
	<td><?php echo $form->dropDownList($model, 'religion', User::getListReligion(), array('class' => 'select-on-profile')); ?></td>
    </tr>
</table>

<?php
/* * ************************Greeting*********************** */
?>
<div class='title-menu'>Greeting</div>
<div class="wrap-greeting">
    <?php
    foreach (Question::getGreetings() as $key => $value) {
	?>
        <div>
    	<div><?php echo h($value) ?></div>
    	<textarea name="Question[<?php echo $key ?>]"><?php
		if (isset($model->more_info[$key])) {
		    echo $model->more_info[$key];
		}
		?></textarea>
        </div>
        <br>
	<?php
    }
    ?>
</div>
<?php
/* * ************************Question*********************** */
?>
<div class='title-menu'>Question</div>
<div class="wrap-greeting">
    <?php
    foreach (Question::getQuestions() as $question) {
	?>
        <div>
    	Q: <?php echo $question['text'] ?><br>
    	A: <select name="Question[<?php echo $question['question_id'] ?>]">
    	    <option value="">Choose</option>
		<?php foreach ($question['list_answer'] as $answer) { ?>
		    <option value="<?php echo $answer ?>" 
		    <?php
		    if (isset($model->more_info[$question['question_id']])) {
			if (strtolower($answer) == strtolower($model->more_info[$question['question_id']])) {
			    echo 'selected';
			}
		    }
		    ?>
			    ><?php echo $answer ?></option>
			<?php } ?>
    	</select>
        </div>
        <br>
	<?php
    }
    ?>
</div>


<input type='submit' name='save' value='Save changes' class='center-column-edit-user btn btn-primary'/>
<?php
$this->endWidget()?>